package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

class zd extends zbz {
   zd() {
      this.c(4176);
   }

   int a(int var1, int var2, ArrayList var3) {
      Collections.sort(var3, new zhx());
      ArrayList var4 = new ArrayList();
      Collections.sort(var3, new zhx());
      int var6 = 0;
      Iterator var7 = var3.iterator();

      while(true) {
         FontSetting var8;
         while(true) {
            zbsx var5;
            if (!var7.hasNext()) {
               if (var6 < var1) {
                  var5 = new zbsx();
                  var5.a = var6;
                  var5.b = var2;
                  com.aspose.cells.b.a.a.ze.a(var4, (Object)var5);
               }

               var5 = new zbsx();
               var5.a = var1;
               var5.b = var2;
               com.aspose.cells.b.a.a.ze.a(var4, (Object)var5);
               int var11 = var4.size();
               if (var11 == 2) {
                  return ((zbsx)var4.get(0)).b;
               }

               this.a((short)(2 + 4 * var11));
               this.c = new byte[this.d()];
               System.arraycopy(com.aspose.cells.b.a.zc.a((short)var11), 0, this.c, 0, 2);
               int var12 = 2;

               for(Iterator var9 = var4.iterator(); var9.hasNext(); var12 += 4) {
                  zbsx var10 = (zbsx)var9.next();
                  System.arraycopy(com.aspose.cells.b.a.zc.a((short)var10.a), 0, this.c, var12, 2);
                  System.arraycopy(com.aspose.cells.b.a.zc.a((short)var10.b), 0, this.c, var12 + 2, 2);
               }

               return -1;
            }

            var8 = (FontSetting)var7.next();
            if (var8.getStartIndex() < var6) {
               if (var8.getStartIndex() + var8.getLength() <= var6) {
                  continue;
               }

               var5 = new zbsx();
               var5.a = var6;
               var5.b = var2;
               com.aspose.cells.b.a.a.ze.a(var4, (Object)var5);
               break;
            }

            if (var8.getStartIndex() > var6) {
               var5 = new zbsx();
               var5.a = var6;
               var5.b = var2;
               com.aspose.cells.b.a.a.ze.a(var4, (Object)var5);
            }

            var5 = new zbsx();
            var5.a = var8.getStartIndex();
            if (var8.c() == null) {
               var5.b = var2;
            } else {
               var5.b = var8.getFont().j();
            }

            com.aspose.cells.b.a.a.ze.a(var4, (Object)var5);
            break;
         }

         var6 = var8.getStartIndex() + var8.getLength();
      }
   }
}
